home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / games / IndiZone / gold / camClass.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  4.6 KB  |  162 lines

  1. /*
  2.  * The original copyright owners of the accompanying source code files have
  3.  * agreed to place such code into the public domain.  Accordingly, anyone
  4.  * who receives or obtains a copy of such source code is freely entitled to
  5.  * reproduce, use and otherwise exploit such code (including the right to
  6.  * make derivative works), at his/her own risk and expense, without any
  7.  * obligation or liability to the original copyright owners.
  8.  *
  9.  * We would appreciate (but do not require) that the following message be
  10.  * included in any derivative works:
  11.  *
  12.  * "Portions of this program were developed by Peter Broadwell, Rob Myers
  13.  * and Robin Schaufler while working in Silicon Valley."
  14.  *
  15.  * The accompanying source code files and related documentation materials
  16.  * are distributed on an "AS IS" basis, without any warranties or
  17.  * guarantees of any kind.  All implied warranties, including the implied
  18.  * warranties of merchantability and of fitness for any particular purpose,
  19.  * are expressly disclaimed.
  20.  */
  21. #include "gl.h"
  22. #include "geom.h"
  23. #include "selectors.h"
  24. #include "class.h"
  25. #include "classIds.h"
  26. #include "mbox.h"
  27. #include "individual.h"
  28. #include "behavior.h"
  29. #include "doers.h"
  30.  
  31. #include "camera.h"
  32.  
  33. extern class indivClass;
  34. model cameraBody, cameraLenz;
  35.  
  36. extern char *take(), *leftright(), *updown(), *inout(), *zoom();
  37. extern char *getMouse(), *home();
  38.  
  39. fcnTable cameraTable[] = {
  40.     TAKE,    take,
  41.     LEFTRIGHT,    leftright,    /* turn (relative to observer) */
  42.     UPDOWN,    updown,
  43.     INOUT,    inout,
  44.     ZOOM,    zoom,        /* adjust the focal length */
  45.     POLL,    getMouse,
  46.     HOME,    home,        /* restore default viewing parameters */
  47.     EOTABLE,
  48. };
  49.  
  50. class cameraClass = {
  51.     &indivClass,
  52.     cameraTable,
  53.     sizeof(camera),
  54.     CAMERA,
  55. };
  56.  
  57. camera cameraTemplate = {
  58.             /*   inst        */
  59.     &cameraClass,    /* myClass pointer    */
  60.     NULL,        /* classFunctions     */
  61.     0,            /* nFunctions        */
  62.             /*   mailbox        */
  63.     NULL,        /* subscribers          */
  64.     NULL,        /* subscribedTo         */
  65.             /*   individual        */
  66.     {10000,10000,10000},/* position        */
  67.     {0,0,0},        /* lastPosition        */
  68.     {1,0,0},        /* delta        */
  69.     {0,0,0},        /* velocity        */
  70.     {0,0,0},        /* avelocity        */
  71.     {0,0,0},        /* acceleration        */
  72.     1.0,        /* speed        */
  73.     {0,0,10},        /* heading        */
  74.     {0,900,0},        /* rotation        */
  75.     {0,0,0},        /* influence        */
  76.     1.0,        /* scale                */
  77.     &cameraBody,    /* model        */
  78.     TRUE,        /* flags        */
  79.     NULL,        /* curVars        */
  80.     NULL,        /* controls        */
  81.             /*    camera            */
  82.     900,        /* focal length    (zoom)    */
  83. };
  84.  
  85. point cameraBodyPoints[] = {
  86.     {    0,    0,    0, },    /* gratuitous vertex 0 */
  87.     {  300,  150,  150, },
  88.     {  300, -150,  150, },
  89.     {  300, -150, -150, },
  90.     {  300,  150, -150, },
  91.     { -300,  150,  150, },
  92.     { -300, -150,  150, },
  93.     { -300, -150, -150, },
  94.     { -300,  150, -150, },
  95. };
  96.  
  97. point cameraLenzPoints[] = {
  98.     {    0,    0,    0, },    /* gratuitous vertex 0 */
  99.     {  300,    0,   30, },
  100.     {  300,  -30,    0, },
  101.     {  300,    0,  -30, },
  102.     {  300,   30,    0, },
  103.     {  400,    0,   40, },
  104.     {  400,  -40,    0, },
  105.     {  400,    0,  -40, },
  106.     {  400,   40,    0, },
  107. };
  108.         /* null terminated polys, double null at end */
  109. long cameraBodyVertices[] = {
  110.     1,2,3,4,0,
  111.     1,4,8,5,0,
  112.     1,5,6,2,0,
  113.     2,6,7,3,0,
  114.     4,3,7,8,0,
  115.     5,8,7,6,0,
  116.     0,
  117. };
  118. long cameraLenzVertices[] = {
  119.     1,5,8,4,0,
  120.     4,8,7,3,0,
  121.     3,7,6,2,0,
  122.     2,6,5,1,0,
  123.     0,
  124. };
  125.  
  126. extern model cameraBody;
  127.  
  128. model cameraLenz = {
  129.     NULL,            /* next model segment          */
  130.     NULL,            /* child model segment         */
  131.     0,                /* geometry compiled yet?      */
  132.     0,                /* compiled geometry object Id */
  133.     cameraLenzPoints,        /* point dictionary            */
  134.     cameraLenzVertices,        /* polygon descriptions        */
  135.     { 350,0,0},            /* centroid               */
  136.     0,                /* color                       */
  137.     0,                /* texture                     */
  138.     FALSE,            /* outlined                    */
  139.     { 0,0,0},            /* rotation                    */
  140.     { 0,0,0},            /* translation                 */
  141.     { 1.0,1.0,1.0},        /* scale               */
  142.     0,                /* declasse               */
  143. };
  144.         
  145. model cameraBody = {
  146.     &cameraLenz,        /* next model segment          */
  147.     NULL,            /* child model segment         */
  148.     0,                /* geometry compiled yet?      */
  149.     0,                /* compiled geometry object Id */
  150.     cameraBodyPoints,        /* point dictionary            */
  151.     cameraBodyVertices,     /* polygon descriptions        */
  152.     { 0,0,0},            /* centroid               */
  153.     0,                /* color                       */
  154.     0,                /* texture                     */
  155.     FALSE,            /* outlined                    */
  156.     { 0,0,0},            /* rotation                    */
  157.     { 0,0,0},            /* translation                 */
  158.     { 1.0,1.0,1.0},        /* scale                       */
  159.     0,                /* declasse               */
  160. };
  161.  
  162.